#include "MeshBuilder.h"

namespace OCPP
{
	MeshBuilder::MeshBuilder()
	{
		
	}

	MeshBuilder::~MeshBuilder()
	{

	}
	MeshList MeshBuilder::loadGLTF(String fileName, Matrix4List instances)
	{
		GLTFLoader loader;
		loader.setInstanceMatrix(instances);
		loader.load(fileName);
		return loader.getMeshes();
	}

	MeshPtr MeshBuilder::buildRect()
	{
		VertexList vertices =
		{
			{{ -1.0f, -1.0f, 0.0f },{ 0.0f, 0.0f, -1.0f },{ 0.0f, 0.0f, 0.0f },{ 0.0f, 0.0f },},
			{{ -1.0f,  1.0f, 0.0f },{ 0.0f, 0.0f, -1.0f },{ 0.0f, 0.0f, 0.0f },{ 0.0f, 1.0f },},
			{{ 1.0f,   1.0f, 0.0f },{ 0.0f, 0.0f, -1.0f },{ 0.0f, 0.0f, 0.0f },{ 1.0f, 1.0f },},
			{{ 1.0f,  -1.0f, 0.0f },{ 0.0f, 0.0f, -1.0f },{ 0.0f, 0.0f, 0.0f },{ 1.0f, 0.0f }}
		};

		IndiceList indices =
		{
			0,2,1,
			0,3,2
		};

		// std::shared_ptr<Texture> texture1(std::make_shared<Texture>("shaders/planks.png", GL_TEXTURE_2D, "diffuse"));
		// std::shared_ptr<Texture> texture2(std::make_shared<Texture>("shaders/planksSpec.png", GL_TEXTURE_2D, "specular"));

		std::shared_ptr<Texture> texture1(std::make_shared<Texture>("shaders/diffuse.png", GL_TEXTURE_2D, "diffuse"));
		std::shared_ptr<Texture> texture2(std::make_shared<Texture>("shaders/normal.png", GL_TEXTURE_2D, "normal"));
		std::shared_ptr<Texture> texture3(std::make_shared<Texture>("shaders/displacement.png", GL_TEXTURE_2D, "displacement"));

		TextureList list =
		{
			texture1,
			texture2,
			texture3
		};

		return std::make_shared<Mesh>(vertices, indices, list);
	}
}